package com.jiazhong.ssm.test02响应数据.controller;

import com.jiazhong.ssm.test02响应数据.pojo.User;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * @Auther:shuXin
 */
@RestController
@RequestMapping("json")
public class JsonController {
    @GetMapping("data")
    public User data() {
        User user = new User();
        user.setName("张三");
        user.setAge(23);
        System.out.println(user.getName() + user.getAge());
        return user;
    }


    @GetMapping("data2")
    public List<User> data2() {
        User user = new User();
        user.setName("张三");
        user.setAge(24);

        List<User> list = new ArrayList<>();
        list.add(user);
        System.out.println(list);
        return list;
    }
}
